package main

import (
	"flag"
	"fmt"
	"github.com/gin-gonic/gin"

	_ "github.com/go-sql-driver/mysql"
)

func main() {
	port := flag.Int("p", 5656, "listen port")
	flag.Usage()
	flag.Parse()
	addr := fmt.Sprintf(":%d", *port)
	e := gin.Default()

	DbInit()

	// router
	r := e.Group("animal")
	{
		r.GET("/", GetAnimal)
		r.POST("/", AddAnimal)
		r.DELETE("/", DelAnimal)
		r.PUT("/", ModifyAnimal)
		r.GET("/:id/:token", GetAnimal)
	}

	e.Run(addr)
}

